package com.hjwoo.app.adpter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hjwoo.app.R;
import com.hjwoo.app.baseviews.BaseLiearAdapter;
import com.hjwoo.app.been.OrderList;

import java.util.List;

/**
 * Created by yangchuan on 2016/5/12.
 */
public class OrderStateAdapter extends BaseLiearAdapter<OrderList>
{
    public OrderStateAdapter(Context context, List list)
    {
        super(context, list);
    }

    public void loadView()
    {
        for (int i = 0; i < list.size(); i++)
        {
            View         view   = View.inflate(context, R.layout.linearcontainer_orderstate, null);
            LinearLayout linear = (LinearLayout) view.findViewById(R.id.orderstate_adapter_linear);//总行高
            ImageView    image  = (ImageView) view.findViewById(R.id.linearcontainer_orderstate_image);//圆形image图标
            View         line   = view.findViewById(R.id.linearcontainer_orderstate_line);//竖线
            TextView     type   = (TextView) view.findViewById(R.id.linearcontainer_orderstate_type);//订单状态
            TextView     detial = (TextView) view.findViewById(R.id.linearcontainer_orderstate_detial);//订单详细
            type.setText(list.get(i).statename);

            if (list.get(i).state.equals("1"))
            {
                image.setBackgroundResource(R.drawable.icon_success);
            }
            if (list.get(i).state.equals("2"))
            {
                image.setBackgroundResource(R.drawable.icon_fail);
            }
            if (!TextUtils.isEmpty(list.get(i).stateStr))
            {
                if (list.get(i).stateStr.contains("万元"))
                {
                    detial.setTextColor(context.getResources().getColor(R.color.home_boder_color));
                }
                if (list.get(i).stateStr.contains("失败"))
                {
                    detial.setTextColor(context.getResources().getColor(R.color.order_red));
                }
                detial.setText(list.get(i).stateStr);
            }
            if (list.get(i).statename.equals("返点已完成"))
            {
                line.setVisibility(View.GONE);
            }
//            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) line.getLayoutParams();
//            layoutParams.height = linear.getHeight() - image.getHeight();
            parent.addView(view);
        }
    }
}
 
